package com.situ.supermarket.controller;



import com.situ.supermarket.entity.User;
import com.situ.supermarket.service.UserService;
import com.situ.supermarket.service.impl.UserServiceImpl;
import com.situ.supermarket.vo.ResultVO;
import com.situ.supermarket.vo.TableVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/user")
public class UserController extends BaseController{
    UserService service = new UserServiceImpl();
    public void page(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.getRequestDispatcher("/WEB-INF/user.jsp").forward(request,response);
    }
    public TableVO select(Integer page, Integer limit, String username, String name) {
        return service.select(page,limit,username,name);
    }
    public TableVO save(User u){
        //派上service 保存进数据库
        return service.save(u);
    }
    public ResultVO delete(Integer id){
        return service.delete(id);
    }
    public User info(Integer id) {
        return service.info(id);
    }
    public TableVO UpdatePassword(String oldPassword,String newPassword,String newPasswordAgain,HttpServletRequest request,HttpServletResponse response){
        return service.UpdatePassword(oldPassword,newPassword,newPasswordAgain,request,response);
    }
    public  User check(String username){
        return  service.selectUsername(username);
    }
}

